package org.eztouch.common.base;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.fasterxml.jackson.annotation.JsonFormat;

public abstract class BaseEntity implements Serializable {
	private static final long serialVersionUID = 1L;
	@ApiModelProperty(hidden=true)
	@TableId(type = IdType.ID_WORKER)
	protected Long id;
	@ApiModelProperty(hidden=true)
	protected Long createBy;
//	@ApiModelProperty(required = false,example = "2017-05-24 08:08:08")
	@ApiModelProperty(hidden=true)
	@JsonFormat(pattern="yyyy-MM-dd HH:ss:mm")
	protected Date createTime;
//	@ApiModelProperty(required = false,example = "0")
	@ApiModelProperty(hidden=true)
	protected Integer isDelete;
	
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getCreateBy() {
		return createBy;
	}

	public void setCreateBy(Long createBy) {
		this.createBy = createBy;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(Integer isDelete) {
		this.isDelete = isDelete;
	}

	/**
	 * 构建查询条件Wrapper实例
	 */
	public abstract Wrapper<? extends BaseEntity> bindingQueryWrapper();

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((createBy == null) ? 0 : createBy.hashCode());
		result = prime * result
				+ ((createTime == null) ? 0 : createTime.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((isDelete == null) ? 0 : isDelete.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BaseEntity other = (BaseEntity) obj;
		if (createBy == null) {
			if (other.createBy != null)
				return false;
		} else if (!createBy.equals(other.createBy))
			return false;
		if (createTime == null) {
			if (other.createTime != null)
				return false;
		} else if (!createTime.equals(other.createTime))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (isDelete == null) {
			if (other.isDelete != null)
				return false;
		} else if (!isDelete.equals(other.isDelete))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "BaseEntity [id=" + id + ", createBy=" + createBy
				+ ", createTime=" + createTime + ", isDelete=" + isDelete + "]";
	}

}
